package system

import (
	"parking-lot-go-dingding/model"
	"time"
)

type DingtalkSystemDepartmentStruct struct {
	Id              uint      `json:"id" gorm:"type:int(10) unsigned auto_increment; NOT NULL; primary_key"`
	CorpId          string    `json:"corp_id" gorm:"type:varchar(50); NOT NULL; COMMENT:'企业ID'"`
	ParentId        int       `json:"parent_id" gorm:"type:int(11); NOT NULL;  COMMENT:'父部门ID'"`
	DeptId          int       `json:"dept_id" gorm:"type:int(11); NOT NULL; COMMENT:'部门ID'"`
	DeptName        string    `json:"dept_name" gorm:"type:varchar(50); NOT NULL; COMMENT:'部门名称'"`
	AutoAddUser     int       `json:"auto_add_user" gorm:"type:tinyint(1); "`
	CreateDeptGroup int       `json:"create_dept_group" gorm:"type:tinyint(1); "`
	CreatedAt       time.Time `json:"created_at" gorm:"type:datetime"`
	UpdatedAt       time.Time `json:"updated_at" gorm:"type:datetime"`
}

func (c *DingtalkSystemDepartmentStruct) TableName() string {
	return "dingtalk_system_department"
}

func (c *DingtalkSystemDepartmentStruct) Create(data DingtalkSystemDepartmentStruct) error {
	db := model.Db
	if err := db.Table(c.TableName()).Create(&data).Error; err != nil {
		return err
	}
	return nil
}
